<{include file="Public/top.html" }>
<style>
    input.param{width:400px !important;}
</style>
	</head>
	<body>
		<div id="warpper">
            <div class="content">
                <div class="location">用户操作</div>
                <!-- 子导航 -->
                <{include file="./nav.html" }>

                <form method="post" class="ui-form" id="addManagerForm">
                <div class="filedSet">
                    <div class="topic">发送短信</div>
                    <div class="form-box border0 border-box">

                        <div class="ui-form-item" >
                            <label class="ui-label">用户手机：</label>
                            <textarea class="ui-textarea" id="phone" name="phone" placeholder="13174128523,13174128523,13174128523"></textarea>
                            <span class="inline-block notes">多个手机<br>使用“,”分割</span>
                        </div>
                        <div class="ui-form-item" >
                            <label class="ui-label">短信模板：</label>
                            <div style="display: inline-block">
                            <{html_radios name="tpl" options=$tplKv selected=$selectedTpl separator="<br />"}>
                            </div>
                        </div>
<div id="param">


</div>

                    </div>
                </div>
                <div class="integral_btn-group">
                    <input type="submit" value="提交" class="ui-button"/>
                </div>
                </form>
            </div>
		</div>

        <{include file="Public/foot.html" }>
		<script>

            function createParamField(text,name){
                var p = '<div class="ui-form-item">'+
                    '<label class="ui-label">'+text+'</label>'+
                    '<input type="text" class="param ui-text"  name="'+name+'" maxlength="20"  required />'+
                    '<i>至多20字符</i>'+
                '</div>'
                $("#param").append(p)
            }

            var SMSEditURL = "<{u('User/sendSms')}>";

			$(function(){
                $('input[type="radio"]').click(function(e){
                    var text=$(e.target).parent().text();
                    var reg = /\$\{(\w+)\}/g;
                    var params=text.match(reg);
                    $('#param').empty();
                    $.each(params,function(i,text){
                        var name=text.replace('${','').replace('}','');
                        createParamField(text,name);
                    })


                });

                $("form").submit(function () {
                    $.getJSON(SMSEditURL,$(this).serialize(), function(data){
                        if(data.status!=0){
                            layer.msg(data.msg);
                            return false;
                        }else{
                            layer.msg(data.msg);
                        }
                    });
                    return false;
                });
			});

		</script>
	</body>
</html>
